package org.example.myai.controller;

import org.example.myai.service.TongYiService;
import org.springframework.ai.image.ImageResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


@RestController
public class ChatController {
    @Autowired
    @Qualifier("tongYiSimpleServiceImpl")
    private TongYiService tongYiSimpleService;

    @GetMapping("/example")
    public String completion(
            @RequestParam(value = "message", defaultValue = "Tell me a joke")
            String message
    ) {

        return tongYiSimpleService.completion(message);
    }
    @Autowired
    @Qualifier("tongYiImagesServiceImpl")
    private TongYiService tongYiImgService;

    @GetMapping("/img")
    public ImageResponse genImg(@RequestParam(value = "prompt",
            defaultValue = "Painting a picture of blue water and blue sky.") String imgPrompt) {

        return tongYiImgService.genImg(imgPrompt);
    }
}
